#include <sdk.h> // Code::Blocks SDK
#include <configurationpanel.h>
#include "CBUELogin.h"
#include <stdlib.h>
#include <gtk/gtk.h>

#include "Login_main.h"

// Register the plugin with Code::Blocks.
// We are using an anonymous namespace so we don't litter the global one.
namespace
{
    PluginRegistrant<CBUELogin> reg(_T("CBUELogin"));
}




// constructor
CBUELogin::CBUELogin()
{
    // Make sure our resources are available.
    // In the generated boilerplate code we have no resources but when
    // we add some, it will be nice that this code is in place already ;)
//    if(!Manager::LoadResource(_T("CBUELogin.zip")))
//    {
//        NotifyMissingFile(_T("CBUELogin.zip"));
//    }
}

// destructor
CBUELogin::~CBUELogin()
{
}

void CBUELogin::OnAttach()
{
    // do whatever initialization you need for your plugin
    // NOTE: after this function, the inherited member variable
    // m_IsAttached will be TRUE...
    // You should check for it in other functions, because if it
    // is FALSE, it means that the application did *not* "load"
    // (see: does not need) this plugin...
}

void CBUELogin::OnRelease(bool appShutDown)
{
    // do de-initialization for your plugin
    // if appShutDown is true, the plugin is unloaded because Code::Blocks is being shut down,
    // which means you must not use any of the SDK Managers
    // NOTE: after this function, the inherited member variable
    // m_IsAttached will be FALSE...
}

int CBUELogin::Execute()
{
    // do your magic ;)
    NotImplemented(_T("CBUELogin::Execute()"));
    return -1;
}

/* add by hanke  */
void CBUELogin::RegisterFunction(wxObjectEventFunction func, wxString label)
{
	wxMenuItem *item = new wxMenuItem(menu, wxID_ANY, label, label);
	menu->Append(item);
	Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, func);
}

void CBUELogin::BuildMenu(wxMenuBar* menuBar)
{
	menu = new wxMenu();

	RegisterFunction(wxCommandEventHandler(CBUELogin::Login), _("Login"));
	menuBar->Insert(menuBar->FindMenu(_("&Tools")) + 1, menu, wxT("&CBUELogin"));
}


void CBUELogin::Login(wxCommandEvent &event)
{
    char argv[]="";
    char *pArgv[]={argv};
    Login_main(0,pArgv);
}

